package Collection.list;

import java.util.ArrayList;
import java.util.ListIterator;

/**
 * @author yt1105
 * @version 1.0
 */
public class loopSolve {
    public static void main(String[] args) {

        ArrayList arrayList = new ArrayList();
        arrayList.add("hello");
        arrayList.add("你好");
        //1.for循环简单的遍历
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println(arrayList.get(i));//这样可以获取到每一个元素
        }
        //2.增强版for循环

        for (Object o : arrayList) {
            System.out.println(o);

        }
        //迭代器的使用
        ListIterator listIterator = arrayList.listIterator();
        while (listIterator.hasNext()) {
            Object next = listIterator.next();
            System.out.println(next);
        }


    }


}

